//
//  AppTools.m
//  newDouban
//
//  Created by dllo on 15/10/30.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "AppTools.h"
#import "AFNetworking.h"

@implementation AppTools

+ (void)getDataWithURL:(NSString *)url block:(AppToolsDataBlock)block
{
    
    //暂时不用
    //AFNetworkReachabilityManager *netWorkManager = [AFNetworkReachabilityManager sharedManager];
    
    //最好编码一下
    NSString *urlEncode = [url stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    
    //NSString *url_string = [NSString stringWithFormat:@"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/activitylist.php"];
    
    
    //[NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];  代表支持所有的接口类型
    
    AFHTTPRequestOperationManager* manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    [manager GET:urlEncode parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //[netWorkManager stopMonitoring];
        
//        if ([url isEqualToString:@"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/activitylist.php"]) {
//            NSLog(@"使用AFN进行get请求 ===  %@",responseObject);
//        } else {
//            NSLog(@"=================%@", responseObject);
//             NSLog(@"可点击放大看是否觉得是咖啡就是打开理发空间的手法看房价快速的拉法基收到了卡房间爱思考了对方接受的拉开房间撒旦了开发空间发快点撒冷风机ADSL看风景撒的路口附近撒旦法离开苏打绿发空间打开撒了房间爱死了都快放假阿斯蒂芬是打发了空间啊速度开了房间阿斯顿发了卡三等奖方式打开了房间卡士大夫");
//        }
//        NSLog(@"使用AFN进行get请求 ===  %@",responseObject);
        //NSLog(@"可点击放大看是否觉得是咖啡就是打开理发空间的手法看房价快速的拉法基收到了卡房间爱思考了对方接受的拉开房间撒旦了开发空间发快点撒冷风机ADSL看风景撒的路口附近撒旦法离开苏打绿发空间打开撒了房间爱死了都快放假阿斯蒂芬是打发了空间啊速度开了房间阿斯顿发了卡三等奖方式打开了房间卡士大夫");
        //block回调
        
        block(responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        NSLog(@"失败==== %@",error);
        
    }];

    
}

@end
